package demo3.controller;

import com.alibaba.csp.sentinel.Entry;
import com.alibaba.csp.sentinel.SphU;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import demo3.handler.MyBlockHandler;
import demo3.handler.MyFallBack;
import demo3.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class HelloController {
    @Autowired
    private HelloService helloService;
    @GetMapping("/hello")
    @SentinelResource(value = "sayHi1",blockHandler = "sayHiHandler",blockHandlerClass = MyBlockHandler.class,
                      fallback = "sayHiBack",fallbackClass = MyFallBack.class)
    public String sayHi(String name){
        String result = null;
        //设置资源入口
//        int i = 1/0;测试坏的
        result = helloService.sayHi(name);
        return result;
    }

}
